/*
 * claplan_tree.h
 *
 *  Created on: 4 Nov 2013
 *      Author: Tom Vercauteren
 */

#ifndef CLAPLAN_TREE_H_
#define CLAPLAN_TREE_H_

#include <vector>
#include <wx/defs.h>
#include <wx/treebase.h>
#include <wx/treectrl.h>
#include <wx/string.h>
#include <wx/gdicmn.h>
#include <wx/validate.h>

#include "claplan_data.h"
#include "claplan_data_change_listener.h"

class ClaplanTree: public wxTreeCtrl, public ClaplanDataChangeListener
{
private:
	ClaplanDataList *modelList;
public:
	ClaplanTree();
	ClaplanTree(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint &pos =
			wxDefaultPosition, const wxSize &size = wxDefaultSize, long style =
	wxTR_DEFAULT_STYLE, const wxValidator &validator = wxDefaultValidator,
			const wxString &name = wxTreeCtrlNameStr);
	virtual ~ClaplanTree();

	void update();
	void claplanDataChanged();

	/**
	 * Check if a claplan file is selected
	 * @return True if a claplan file is selected
	 */
	bool isClaplanFileSelected() const;

	/**
	 * Add a claplan name to the tree.
	 * @param name Name of the claplan
	 * @return
	 * <ul>
	 * 	<li> 1 : claplan has been added </li>
	 * 	<li> 0 : nothing was added </li>
	 * 	<li>-1 : root of the tree was not OK </li>
	 * </ul>
	 */
	int addClaplan(const std::string &name);
	/**
	 * Add a claplan and / or it's subsection to the tree.
	 * @param name Name of the claplan
	 * @param section Section name
	 * @return
	 * <ul>
	 * 	<li> 1 : claplan and / or section have been added </li>
	 * 	<li> 0 : nothing was added </li>
	 * 	<li>-1 : root of the tree was not OK</li>
	 * </ul>
	 */
	int addClaplanSection(const std::string &name, const std::string &section);
	/**
	 * Remove the claplan name from the tree.
	 * @param name Name of the claplan
	 * @return
	 * <ul>
	 * 	<li> 1 : claplan and it's subsection have been removed </li>
	 * 	<li> 0 : nothing was removed </li>
	 * 	<li>-1 : root of the tree was not OK</li>
	 * </ul>
	 */
	int removeClaplan(const std::string &name);
	/**
	 * Remove a claplan section from the tree.
	 * @param name Name of the claplan
	 * @param section Section name
	 * @return
	 * <ul>
	 * 	<li> 1 : subsection has been removed </li>
	 * 	<li> 0 : nothing was removed </li>
	 * 	<li>-1 : root of the tree was not OK</li>
	 * </ul>
	 */
	int removeClaplanSection(const std::string &name, const std::string &section);
};

#endif /* CLAPLAN_TREE_H_ */
